Skip to content

Convert syntax file to Typescript #20

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 2, 2019

Conversation

PanAeon
Copy link
Contributor

@PanAeon PanAeon commented May 1, 2019

Fixes #15
I have converted the original PLIST file with plutil to Json and then used it practically verbatim in typescript. Also I have added validation against the tmLanguage json schema from which the typescript interfaces were also generated.

I have checked the ouptut tmLanguage.json file, and it is identical to the original (plutil converted) json.

One note is that I have added output file to the gitignore, but that means if the project hasn't been built then it is possible to package extension without the output file! vsce package doesn't throw any errors when file is missing, not sure if the publish process will account for this. Not sure how this can be avoided, except commiting generated file which is a bit lame.

Copy link
Contributor

@olafurpg olafurpg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, thank you for your hard work porting the tmLanguage file to TypeScript! This is a great contribution to the Scala community 🙏 I am unqualified to review actual changes, at a quick glance it looks great. Is there some way to validate the fidelity of this translation?

@PanAeon
Copy link
Contributor Author

PanAeon commented May 2, 2019

I have converted the resulting json syntax back to plist format with plutil -convert xml1 Scala.tmLanguage.json -o Scala.tmLanguage. Diff. It looks identical, except one field is reordered and I have added a json schema just in case.
Of course I've also run the extension to verify that it works (by packaging it and installing local version), but you (or someone else) might want to do the same to cross-check.

Also I've added pre-install and pre-package scripts and actively chicking that generated file is in place before packaging the extension.

Copy link
Contributor

@olafurpg olafurpg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just installed the extension locally and confirmed that it works as expected. LGTM 👍 Fantastic work @PanAeon.

To followup, I will setup CI to ensure that the typescript code continues to generate the syntax definition without errors. I will also configure the CI to automatically release a new version on tag push so that new changes get published faster to the Marketplace.

@olafurpg olafurpg merged commit 8a4ae57 into scala:master May 2, 2019
@smarter
Copy link
Member

smarter commented May 2, 2019

Wait, github relies on this repository having a .tmLanguage file to provide syntax highlighting for Scala on github.com (https://github.com/github/linguist/tree/master/vendor). Generating the file from a better format is great but the output still needs to be committed.

@smarter
Copy link
Member

smarter commented May 2, 2019

Hmm, it seems that JSON grammars might also be accepted, but I have no idea how to test if the one added here is going to be correctly interpreted by linguist.

@PanAeon
Copy link
Contributor Author

PanAeon commented May 2, 2019 via email

@smarter
Copy link
Member

smarter commented May 2, 2019

Apparently json can work but it has to be in a folder called grammars or syntaxes: https://github.com/github/linguist/blob/9116c90fcbb82ac03b4b33c58cfbde1fcf745e99/tools/grammars/compiler/loader.go#L125

@smarter
Copy link
Member

smarter commented May 2, 2019

One way to find out for sure would be to make a PR against linguist updating the vscode-scala-syntax submodule to the latest commit on master.

olafurpg added a commit to olafurpg/vscode-scala-syntax that referenced this pull request May 2, 2019
This file is needed by github/linguist for syntax highlighting on
github.com.
Followup from comment in scala#20 (comment)
@olafurpg
Copy link
Contributor

olafurpg commented May 2, 2019

I opened #23 to unignore the Scala.tmLanguage.json file

@PanAeon
Copy link
Contributor Author

PanAeon commented May 3, 2019

@smarter ,
on the linguist contributing page there're some instruction which I believe can help checking it locally. But I apologise, I just can't make it run on my work macbook. Apparently I have to reinstall the whole system)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use another format for tmLanguage
4 participants